import instance from '../utils/request'

export const getGoodsList = () => {
    return instance({
        method: 'get',
        url: '/api/products'
    })
}

// 删除
export const deleteGood = (id) => {
    return instance({
        method: 'delete',
        url: `/api/products/${id}`,
    })
}

// 获取商品详情
export const getGoodDetail = (id) => {
    return instance({
        method: 'get',
        url: `/api/products/${id}`
    })
}

export const updateGoods = (id, name, description, price) => {
    return instance({
        method: 'put',
        url: `/api/products/${id}`,
        data: {
            name,
            description,
            price
        }
    })
}

export const createGood = (name, description, price) => {
    return instance({
        method: 'post',
        url: '/api/products',
        data: {
            name,
            description,
            price
        }
    })
}